#ifndef KMYNODE_H
#define KMYNODE_H

#include <vector>
using namespace std;

#include "../KmyICanvas.h"
#include "../KmyVector.h"
#include "../DrawTask.h"

class KmyNode
{
public:
    KmyNode();
    virtual ~KmyNode();

    void finalize();

    int id;
    KmyNode* parent;

    enum NodeType{
        NODE_TYPE_BASE = 0,
        NODE_TYPE_IMAGE,
        NODE_TYPE_LAYER,
        NODE_TYPE_WORLD,
        NODE_TYPE_MAP,
        NODE_TYPE_SPRITE,
        NODE_TYPE_TEXTLAYER,
        NODE_TYPE_TRANS,
        NODE_TYPE_BUTTON,
        NODE_TYPE_MENU
    };

    virtual int getNodeType();

    virtual void addChild(KmyNode* child);
    virtual void removeChild(KmyNode* child);

    virtual void logic();
    virtual void render(KmyICanvas* screen);

    static int createID();

    virtual int getGlobalX();
    virtual int getGlobalY();
    int getGlobalZ();

    int getX();
    int getY();
    int getZ();
    void setX(int x);
    void setY(int y);
    void setZ(int z);
    void move(int dx, int dy, int dz);

    bool visible;
protected:
    int x, y, z;
    KmyVector child_list;
//    St_Rect max_range;
//    bool isInScreen(KmyICanvas* screen);

    DrawTask *drawtask;
    bool is_updated;
private:

    /** id计数器从100000开始 */
    static int id_counter;
};

#endif // KMYNODE_H
